export const initHeader = async () => {

  // search
  loadScript('/html/assets/js/theme-change.js')
  loadScript('/html/assets/js/modernizr.custom.js')
  loadScript('/html/assets/js/classie.js')
  loadScript('/html/assets/js/search.js')

  // 监听滚动事件
  useEventListener(window, 'scroll', () => {
    var scroll = $(window).scrollTop()
    if (scroll >= 80) {
      $("#site-header").addClass("nav-fixed")
    } else {
      $("#site-header").removeClass("nav-fixed")
    }
  }, true)

  //Main navigation Active Class Add Remove
  useEventListener('.navbar-toggler', 'click', () => {
    $("header").toggleClass("active")
  })

  $(document).on("ready", function () {
    if ($(window).width() > 991) {
      $("header").removeClass("active");
    }
    $(window).on("resize", function () {
      if ($(window).width() > 991) {
        $("header").removeClass("active");
      }
    });
  });

  /*
    移动端点击菜单按钮
    disable body scroll which navbar is in active
  */
  $(function () {
    $('.navbar-toggler').click(function () {
      $('body').toggleClass('noscroll');
    })
  })
}
